package nc.vo.ct.utility;

public class CTUtility
{
  public static final String getCtTypeControlCondition()
  {
    StringBuffer sbControlAmountSQL = new StringBuffer(120);
    sbControlAmountSQL.append(" type.controltype = ").append(1).append(" AND ISNULL(ct_b.ordnum, 0) < ISNULL(ct_b.amount, 0) ");

    StringBuffer sbControlSumSQL = new StringBuffer(130);
    sbControlSumSQL.append(" type.controltype = ").append(2).append(" AND ISNULL( ct_b.ordsum, 0) < ISNULL(ct_b.natitaxsummny, 0) ");

    StringBuffer sbControlAmountAndSum = new StringBuffer(230);
    sbControlAmountAndSum.append(" type.controltype = ").append(3).append(" AND ( ISNULL(ct_b.ordnum, 0) < ISNULL(ct_b.amount, 0) ").append(" OR ISNULL( ct_b.ordsum, 0) < ISNULL(ct_b.natitaxsummny, 0) ) ");

    StringBuffer sbOtherControlType = new StringBuffer(90);
    sbOtherControlType.append(" type.controltype = ").append(0).append(" OR type.controltype = ").append(4).append(" OR type.controltype = ").append(5);
    sbOtherControlType.append(" OR type.controltype =6  OR type.controltype=7 OR type.controltype=8 OR type.controltype=9 OR type.controltype=10 ");

    StringBuffer sbAllCtrlCondition = new StringBuffer(600);
    sbAllCtrlCondition.append(" AND (").append(sbOtherControlType.toString()).append(" OR (").append(sbControlAmountSQL).append(") OR (").append(sbControlSumSQL).append(") OR (").append(sbControlAmountAndSum).append(") ) ");

    return sbAllCtrlCondition.toString();
  }
}